package io.litchi.starter.jjwt.autoconfig;

import io.litchi.starter.jjwt.JwtManager;
import io.litchi.starter.jjwt.properties.JjwtProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 *
 * @author helang
 * @since 2025-09-19
 */
@Configuration
@EnableConfigurationProperties(JjwtProperties.class)
@ConditionalOnClass(JwtManager.class)
public class JjwtAutoConfiguration {

    @Bean
    @ConditionalOnMissingClass
//    @Primary //主要的bean 会覆盖其他bean 除非其他的添加了该注解
    public JwtManager jwtManager(JjwtProperties jwtProperties) {
        return new JwtManager(jwtProperties);
    }
}